<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    ul li {
        list-style: none;
    }

    .no-ulhd {
        position: absolute;
        top: 0;
        left: 50%;
        z-index: 20;
        transform: translateX(-50%);
    }

    .no-ulhd li:nth-child(1) {
        border-radius: 32px 0 0 32px;
    }

    .no-ulhd li {
        width: 120px;
        height: 48px;
        border-radius: 0 32px 32px 0;
        border: 1px solid #7C90A7;
        float: left;
        line-height: 48px;
        text-align: center;
        font-size: 18px;
        cursor: pointer;
    }

    .no-ulhd li.active {
        color: #51F1F1;
        border: 1px solid #51F1F1;
        box-sizing: border-box;
        height: 50px;
        /* transform: matrix(-1, 0, 0, 1, 0, 0); */
    }
</style>

<body>
    <div id="app">
        <div>
            <ul class="no-ulhd">
                <li :class="index==curId ? 'active' : ''" v-for="(item,index) in ['a', 'b']" @click="selectTab(index)">
                    {{index==curId}}{{item}}{{curId}}
                </li>
            </ul>
        </div>
        <div id="mapMain" v-show="curId==0" class="content_0"
            style="height:inherit;position: relative;width:100%;margin:0;">
            curId==0
        </div>
        <div id="topoMain" v-show="curId==1" class="content_0"
            style="height:inherit;position: relative;width:100%;margin:0;">
            curId==1
        </div>
    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.0/vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data() {
                return {
                    curId: window.localStorage.getItem('curId') ? window.localStorage.getItem('curId') : 0
                }
            },
            methods: {
                selectTab(index) {
                    this.curId = index;
                    // if (this.curId == 0) {
                    //     this.getData();
                    // } else {
                    //     this.getDataList().then(() => {
                    //         this.initData();
                    //     })
                    // }
                }
            },
            watch: {
                curId: {
                    // 每个属性值发生变化就会调用这个函数
                    handler(newVal, oldVal) {
                        console.log('oldVal:', oldVal)
                        console.log('newVal:', newVal)
                        if (newVal) {
                            window.localStorage.setItem('curId', newVal)
                        } else {
                            window.localStorage.setItem('curId', 0)
                        }
                    },
                    // 立即处理 进入页面就触发
                    immediate: true,
                    // 深度监听 属性的变化
                    deep: true
                }
            }
        });
    </script>
</body>

</html>